/* Copyright - Apache License 2.0
 * 
 * The project "kyou" is
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.kyou.data.dquery;

import net.kyou.exception.KyouErr;
import net.kyou.exception.KyouException;

import org.junit.Assert;
import org.junit.Test;

public class DPathTest {
//    @Test
//    public void test() {
//        DPath a = new DPath("#.a");
//        Assert.assertEquals("#.a", a.toString());
//        Assert.assertEquals(2, a.segments.length);
//        Assert.assertEquals("#.a", a.path);
//        Assert.assertEquals("#", a.segments[0].body);
//        Assert.assertEquals(-1, a.segments[0].index);
//        Assert.assertEquals("a", a.segments[1].body);
//        Assert.assertEquals(-1, a.segments[1].index);
//
//    }
//
//    @Test
//    public void testEx() {
//        try {
//            new DPath(null);
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//        }
//
//        try {
//            new DPath("");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//        }
//
//        try {
//            new DPath("a..b");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath(".abcde");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a[3]b");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a[-3]");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a[b]");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a[3");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//        
//        try {
//            new DPath("a[3[]");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a]3");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a[]");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a[2.3]");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a[*]");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("[3]");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathSegmentSyntaxError, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("a");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathMustStartWithRoot, ((KyouException) ex.getCause()).err);
//        }
//
//        try {
//            new DPath("#[2].a");
//            Assert.fail();
//        } catch (KyouException ex) {
//            Assert.assertEquals(KyouErr.Schema.DPathSyntaxError, ex.err);
//            Assert.assertEquals(KyouErr.Schema.DPathRootCannotHaveIndex, ((KyouException) ex.getCause()).err);
//        }
//    }
}
